<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
<meta name="viewport"
      content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">

    <meta name="author" content="WD">





<title>Mysql学习笔记(一) | WD&#39;s blog</title>



    <link rel="icon" href="/favicon1.ico">




    <!-- stylesheets list from _config.yml -->
    
    <link rel="stylesheet" href="/css/style.css">
    



    <!-- scripts list from _config.yml -->
    
    <script src="/js/script.js"></script>
    
    <script src="/js/tocbot.min.js"></script>
    
    <script src="/js/snow.js"></script>
    



    
    
        
    


<meta name="generator" content="Hexo 5.4.0"></head>
<body>
    <div class="wrapper">
        <header>
    <nav class="navbar">
        <div class="container">
            <div class="navbar-header header-logo"><a href="/">WD&#39;s Blog</a></div>
            <div class="menu navbar-right">
                
                    <a class="menu-item" href="/archives">Posts</a>
                
                    <a class="menu-item" href="/category">Categories</a>
                
                    <a class="menu-item" href="/tag">Tags</a>
                
                    <a class="menu-item" href="/about">About</a>
                
                <input id="switch_default" type="checkbox" class="switch_default">
                <label for="switch_default" class="toggleBtn"></label>
            </div>
        </div>
    </nav>

    
    <nav class="navbar-mobile" id="nav-mobile">
        <div class="container">
            <div class="navbar-header">
                <div>
                    <a href="/">WD&#39;s Blog</a><a id="mobile-toggle-theme">·&nbsp;Light</a>
                </div>
                <div class="menu-toggle" onclick="mobileBtn()">&#9776; Menu</div>
            </div>
            <div class="menu" id="mobile-menu">
                
                    <a class="menu-item" href="/archives">Posts</a>
                
                    <a class="menu-item" href="/category">Categories</a>
                
                    <a class="menu-item" href="/tag">Tags</a>
                
                    <a class="menu-item" href="/about">About</a>
                
            </div>
        </div>
    </nav>

</header>
<script>
    var mobileBtn = function f() {
        var toggleMenu = document.getElementsByClassName("menu-toggle")[0];
        var mobileMenu = document.getElementById("mobile-menu");
        if(toggleMenu.classList.contains("active")){
           toggleMenu.classList.remove("active")
            mobileMenu.classList.remove("active")
        }else{
            toggleMenu.classList.add("active")
            mobileMenu.classList.add("active")
        }
    }
</script>
        <div class="main">
            <div class="container">
    
    
        <div class="post-toc">
    <div class="tocbot-list">
    </div>
    <div class="tocbot-list-menu">
        <a class="tocbot-toc-expand" onclick="expand_toc()">Expand all</a>
        <a onclick="go_top()">Back to top</a>
        <a onclick="go_bottom()">Go to bottom</a>
    </div>
</div>

<script>
    document.ready(
        function () {
            tocbot.init({
                tocSelector: '.tocbot-list',
                contentSelector: '.post-content',
                headingSelector: 'h1, h2, h3, h4, h5',
                collapseDepth: 1,
                orderedList: false,
                scrollSmooth: true,
            })
        }
    )

    function expand_toc() {
        var b = document.querySelector(".tocbot-toc-expand");
        tocbot.init({
            tocSelector: '.tocbot-list',
            contentSelector: '.post-content',
            headingSelector: 'h1, h2, h3, h4, h5',
            collapseDepth: 6,
            orderedList: false,
            scrollSmooth: true,
        });
        b.setAttribute("onclick", "collapse_toc()");
        b.innerHTML = "Collapse all"
    }

    function collapse_toc() {
        var b = document.querySelector(".tocbot-toc-expand");
        tocbot.init({
            tocSelector: '.tocbot-list',
            contentSelector: '.post-content',
            headingSelector: 'h1, h2, h3, h4, h5',
            collapseDepth: 1,
            orderedList: false,
            scrollSmooth: true,
        });
        b.setAttribute("onclick", "expand_toc()");
        b.innerHTML = "Expand all"
    }

    function go_top() {
        window.scrollTo(0, 0);
    }

    function go_bottom() {
        window.scrollTo(0, document.body.scrollHeight);
    }

</script>
    

    
    <article class="post-wrap">
        <header class="post-header">
            <h1 class="post-title">Mysql学习笔记(一)</h1>
            
                <div class="post-meta">
                    
                        Author: <a itemprop="author" rel="author" href="/about/">WD</a>
                     &nbsp;

                    
                        <span class="post-time">
                        Date: <a href="#">June 9, 2019&nbsp;&nbsp;16:36:25</a>
                        </span>
                     &nbsp;
                    
                        <span class="post-category">
                    Category:
                            
                                <a href="/categories/Mysql/">Mysql</a>
                            
                        </span>
    <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <br>
    <span id="busuanzi_container_site_pv">总阅读量:<a href="#"><span id="busuanzi_value_page_pv"></span></a>次</span>&nbsp;
    <span class="post-count">文章字数:<a href="#">550</span></a>&nbsp;
     <span class="post-count">阅读时长:<a href="#">1</span>min</a>
                    
                </div>
            
        </header>

        <div class="post-content">
            <h2 id="1-关系代数"><a href="#1-关系代数" class="headerlink" title="1.关系代数"></a>1.关系代数</h2><div class="table-container">
<table>
<thead>
<tr>
<th style="text-align:center">运算符</th>
<th style="text-align:center">含义</th>
<th style="text-align:center">运算符</th>
<th style="text-align:center">含义</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">∪</td>
<td style="text-align:center">并</td>
<td style="text-align:center">&gt;</td>
<td style="text-align:center">大于</td>
</tr>
<tr>
<td style="text-align:center">-</td>
<td style="text-align:center">差</td>
<td style="text-align:center">≥</td>
<td style="text-align:center">大于等于</td>
</tr>
<tr>
<td style="text-align:center">∩</td>
<td style="text-align:center">交</td>
<td style="text-align:center">&lt;</td>
<td style="text-align:center">小于</td>
</tr>
<tr>
<td style="text-align:center">×</td>
<td style="text-align:center">笛卡尔积</td>
<td style="text-align:center">≤</td>
<td style="text-align:center">小于等于</td>
</tr>
<tr>
<td style="text-align:center"></td>
<td style="text-align:center"></td>
<td style="text-align:center">&lt;&gt;</td>
<td style="text-align:center">不等于</td>
</tr>
<tr>
<td style="text-align:center">σ</td>
<td style="text-align:center">选择</td>
<td style="text-align:center">^</td>
<td style="text-align:center">与</td>
</tr>
<tr>
<td style="text-align:center">π</td>
<td style="text-align:center">投影</td>
<td style="text-align:center">∨</td>
<td style="text-align:center">或</td>
</tr>
<tr>
<td style="text-align:center"><img src="https://img-blog.csdnimg.cn/20190609162945603.png" alt=""></td>
<td style="text-align:center">连接</td>
<td style="text-align:center"></td>
<td style="text-align:center"></td>
</tr>
<tr>
<td style="text-align:center">÷</td>
<td style="text-align:center">并</td>
<td style="text-align:center"></td>
</tr>
</tbody>
</table>
</div>
<p><img src="https://img-blog.csdnimg.cn/20190609162957865.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwMTgxNTky,size_16,color_FFFFFF,t_70" alt=""> <img src="https://img-blog.csdnimg.cn/20190609163008345.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwMTgxNTky,size_16,color_FFFFFF,t_70" alt=""></p>
<ul>
<li>并<blockquote>
<ul>
<li>R ∪ S 是将两个表合并，重复的行保留一行，其余去掉<br><img src="https://img-blog.csdnimg.cn/20190609163019398.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwMTgxNTky,size_16,color_FFFFFF,t_70" alt=""></li>
</ul>
</blockquote>
</li>
<li>差<blockquote>
<ul>
<li>R - S 是对R表操作，减去出现在S中的行<br><img src="https://img-blog.csdnimg.cn/20190609163032970.png" alt=""></li>
</ul>
</blockquote>
</li>
<li>交<blockquote>
<ul>
<li>R ∩ S 是既属于R又属于S的行<br><img src="https://img-blog.csdnimg.cn/20190609163044162.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwMTgxNTky,size_16,color_FFFFFF,t_70" alt=""></li>
</ul>
</blockquote>
</li>
<li><p>笛卡尔积</p>
<blockquote>
<ul>
<li>R × S 是R中每一行与S中所有行匹配，列数是原来的两倍<br><img src="https://img-blog.csdnimg.cn/20190609163054631.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwMTgxNTky,size_16,color_FFFFFF,t_70" alt=""></li>
</ul>
</blockquote>
</li>
<li><p>选择</p>
<blockquote>
<ul>
<li>选择运算是从关系R中选取使逻辑表达式F为真的元组，是从行的角度进行的运算<br><img src="https://img-blog.csdnimg.cn/20190609163106556.png" alt=""></li>
</ul>
</blockquote>
</li>
<li><p>投影</p>
<blockquote>
<ul>
<li>投影操作主要是从列的角度进行运算,但投影之后不仅取消了原关系中的某些列，而且还可能取消某些元组（避免重复行）<br><img src="https://img-blog.csdnimg.cn/20190609163116308.png" alt=""></li>
</ul>
</blockquote>
</li>
<li><p>连接</p>
</li>
</ul>
<ol>
<li>一般连接<blockquote>
<ul>
<li>在笛卡尔积的基础上选择A、B满足关系的那些行，A和B分别为R和S上度数相等且可比的属性组</li>
</ul>
</blockquote>
</li>
</ol>
<p><img src="https://img-blog.csdnimg.cn/20190609163134542.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwMTgxNTky,size_16,color_FFFFFF,t_70" alt=""></p>
<pre><code>2. 等值连接
</code></pre><blockquote>
<ul>
<li>从关系R与S的广义笛卡尔积中选取A、B属性值相等的那些元组</li>
</ul>
</blockquote>
<p><img src="https://img-blog.csdnimg.cn/2019060916315072.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwMTgxNTky,size_16,color_FFFFFF,t_70" alt=""></p>
<ol>
<li>自然连接<blockquote>
<ul>
<li>两个关系中进行比较的分量必须是相同的属性组<br>在结果中把重复的属性列去掉</li>
</ul>
</blockquote>
</li>
</ol>
<p><img src="https://img-blog.csdnimg.cn/20190609163349143.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwMTgxNTky,size_16,color_FFFFFF,t_70" alt=""></p>
<ol>
<li>外连接<blockquote>
<ul>
<li>如果把舍弃的元组也保存在结果关系中，而在其他属性上填空值(Null)，这种连接就叫做外连接<br><img src="https://img-blog.csdnimg.cn/20190609163438148.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwMTgxNTky,size_16,color_FFFFFF,t_70" alt=""></li>
</ul>
</blockquote>
</li>
<li>左外连接<blockquote>
<ul>
<li>如果只把左边关系R中要舍弃的元组保留就叫做左外连接</li>
</ul>
</blockquote>
</li>
<li>右外连接<blockquote>
<ul>
<li>如果只把右边关系S中要舍弃的元组保留就叫做右外连接<br><img src="https://img-blog.csdnimg.cn/20190609163454722.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwMTgxNTky,size_16,color_FFFFFF,t_70" alt=""></li>
</ul>
</blockquote>
</li>
</ol>
<ul>
<li>除<blockquote>
<ul>
<li>引入象集的概念，求某些属性的象集，就是他所对应行其他属性的集合<br><img src="https://img-blog.csdnimg.cn/20190609163509640.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwMTgxNTky,size_16,color_FFFFFF,t_70" alt=""></li>
<li>求除法运算的一般步骤</li>
</ul>
</blockquote>
</li>
</ul>
<ol>
<li>找RS的共同属性（组合）</li>
<li>在R中求其他属性在共同属性上的所有象集</li>
<li>在S中求共同属性上的投影</li>
<li>检查R中求出的象集能否包含3中的投影<br><img src="https://img-blog.csdnimg.cn/20190609163521415.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwMTgxNTky,size_16,color_FFFFFF,t_70" alt=""></li>
</ol>
<ul>
<li>一般碰到至少/全部的关键词都要用到除法运算</li>
</ul>

        </div>

        
            <section class="post-copyright">
                
                    <p class="copyright-item">
                        <span>Author:</span>
                        <span><a href="/about/">WD</a></span>
                    </p>
                
                
                    <p class="copyright-item">
                        <span>Permalink:</span>
                        <span><a href="https://did321.gitee.io/2019/06/09/Mysql%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0-%E4%B8%80/">https://did321.gitee.io/2019/06/09/Mysql%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0-%E4%B8%80/</a></span>
                    </p>
                
                
                    <p class="copyright-item">
                        <span>License:</span>
                        <span>Copyright (c) 2022 <a target="_blank" rel="noopener" href="http://creativecommons.org/licenses/by-nc/4.0/">CC-BY-NC-4.0</a> LICENSE</span>
                    </p>
                
                
                     <p class="copyright-item">
                         <span>Slogan:</span>
                         <span><a href="#">The blog is my giant.</a></span>
                     </p>
                

            </section>
        
        <section class="post-tags">
            <div>
                <span>Tag(s):</span>
                <span class="tag">
                    
                    
                        <a href="/tags/Mysql/"># Mysql</a>
                    
                        <a href="/tags/%E6%95%B0%E6%8D%AE%E5%BA%93/"># 数据库</a>
                    
                        
                </span>
            </div>
            <div>
                <a href="javascript:window.history.back();">back</a>
                <span>· </span>
                <a href="/">home</a>
            </div>
        </section>
        <section class="post-nav">
            
                <a class="prev" rel="prev" href="/2019/06/12/Mysql%E5%AE%89%E8%A3%85%E4%B8%8E%E9%85%8D%E7%BD%AE-%E6%94%AF%E6%8C%81%E4%B8%AD%E6%96%87/">Mysql安装与配置+支持中文</a>
            
            
            <a class="next" rel="next" href="/2019/05/11/Github%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B%E8%AF%A6%E8%A7%A3-%E4%BA%8C-%E2%80%94%E2%80%94git%E7%9A%84%E4%BD%BF%E7%94%A8/">Github使用教程详解(二)——git的使用</a>
            
        </section>
        <br>
        <br>
    
    <script src="//unpkg.com/valine/dist/Valine.min.js"></script>
    <div id="vcomments"></div>
    <script>
        new Valine({
    el: '#vcomments' ,

    appId: 'JvFy3ebVLo2rUYgHaMweJyXX-MdYXbMMI',
    appKey: 'TCFxfjDAM8UmERPEgYXJmT40',
    serverURLs: 'https://JvFy3ebV.api.lncldglobal.com', 
    placeholder: '----评论区----留下你的评论，作者会定期回复！在昵称处填写QQ号可自动获取邮箱和QQ头像（保护QQ邮箱隐私）',
    enableQQ: true,
    requiredFields: ['nick'],
});
    </script>

    </article>
</div>

        </div>
        <footer id="footer" class="footer">
    <div class="copyright">
        <span>© WD | Powered by <a href="https://hexo.io" target="_blank">Hexo</a> & <a href="https://github.com/Siricee/hexo-theme-Chic" target="_blank">Chic</a></span>
    </div>
</footer>

    </div>
</body>

</html>
